package com.kmproject.haifu.mvp.model;

import android.app.Application;

import com.google.gson.Gson;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import com.jess.arms.di.scope.ActivityScope;
import com.kmproject.haifu.mvp.contract.AddUserContract;
import com.kmproject.haifu.mvp.model.api.service.UserService;
import com.kmproject.haifu.mvp.model.entity.ResultBean;
import com.kmproject.haifu.mvp.model.entity.User;

import java.util.List;

import javax.inject.Inject;

import io.reactivex.Observable;
import io.reactivex.functions.Function;

//import okhttp3.MultipartBody;


@ActivityScope
public class AddUserModel extends BaseModel implements AddUserContract.Model {
    @Inject
    Gson mGson;
    @Inject
    Application mApplication;

    @Inject
    public AddUserModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mGson = null;
        this.mApplication = null;
    }

    @Override
    public Observable<ResultBean<User>> addUser(String userStr) {
        return mRepositoryManager.obtainRetrofitService(UserService.class)
                .addUser(userStr)
                .map(new Function<ResultBean<User>, ResultBean<User>>() {
                    @Override
                    public ResultBean<User> apply(ResultBean<User> userResultBean) throws Exception {
                        return userResultBean;
                    }
                });
    }

//    @Override
//    public Observable<String> updateHeader(MultipartBody.Part partList) {
//        return null;
//        return mRepositoryManager.obtainRetrofitService(UserService.class).uploadMemberIcon(partList)
//                .map(new Function<String, String>() {
//                    @Override
//                    public String apply(String s) throws Exception {
//                        return s;
//                    }
//                });
//    }
}